POV-Ray : Newsgroups : povray.general : Sphere with longitudes and latitudes? : Re: Sphere with longitudes and latitudes? Server Time
31 Jul 2024 10:27:12 EDT (-0400)
  Re: Sphere with longitudes and latitudes?  
From: M a r c
Date: 12 Nov 2007 02:44:02
Message: <47380442$1@news.povray.org>

47377c4d@news.povray.org...
>
> Why not build your lines with some tori and make an object_pattern with 
> them?
> You could keep constant width lines that way.
>
> Marc

#include "colors.inc"
#include"math.inc"

global_settings {
  assumed_gamma 1.0
}

// ----------------------------------------

camera {
  location  <0.0, 2, -3.0>
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}



light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

// ----------------------------------------

#declare Sphere_rad=1;
#declare Line_width=0.0025;
#declare Long_number=24;
#declare Lat_number=12;

//construction of the longitude lines
#declare Line_long=torus{Sphere_rad,Line_width rotate x*90}
#declare Cnt_long=0;
#declare Long=union{
#while(Cnt_long<Long_number)
object{Line_long rotate y*360*Cnt_long/Long_number}
#declare Cnt_long=Cnt_long+1;
#end
}

//construction of the latitude lines
#declare Cnt_lat=0;
#declare Lat=union{
#while (Cnt_lat< Lat_number)
torus{Sphere_rad*cosd(90*Cnt_lat/Lat_number),Line_width translate 
y*Sphere_rad*sind(90*Cnt_lat/Lat_number)}
#declare Cnt_lat=Cnt_lat+2;
#end
}

#declare Lines=union{
object{Long}
object{Lat}  //North hemisphere
object{Lat scale<1,-1,1>} //South hemisphere
}

sphere {
  0.0, Sphere_rad
  texture {
    pigment{
  object {
    Lines
    color rgb <0,0,0.5>,      // outside object
    color rgb <0,1,0>       // inside object
  }

}
    finish{
      specular 0.6
    }
  }
}


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.